package com.lnsoft.cac.server.handle.codec.frameMessage;


import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;
import lombok.NonNull;

@Data
/**
 * 配置/状态交互---装置调试命令下发
 * */
public class Cfg_DebugDownload_Cfm {
    private byte[] Debug_Command_Response;          //n byte            装置调试命令响应（ASCII码、厂家自定义，用$符代替回车换行符）


    public ByteBuf toByteBuf() throws Exception{
        if (Debug_Command_Response == null) {
            throw new Exception("调试命令 设置异常");
        }
        ByteBuf bf = Unpooled.buffer();
        bf.writeBytes(Debug_Command_Response);
        return bf;
    }


    //  解析 { 配置/状态交互---装置调试命令下发 - 确认} 帧报文内容区 到消息体中
    public static Cfg_DebugDownload_Cfm decFrameBody(@NonNull byte[] frameBody) throws Exception {
        ByteBuf bf = Unpooled.wrappedBuffer(frameBody);
        Cfg_DebugDownload_Cfm msg = new Cfg_DebugDownload_Cfm();
        int len = frameBody.length;
        byte[] Debug_Command_Response = new byte[len];
        bf.getBytes(0, Debug_Command_Response);
        msg.setDebug_Command_Response(Debug_Command_Response);
        return msg;
    }

}
